<template>
	<view class="content">
		<view class="top">
			<image src="../../static/me_bg.png" mode="" class="bg"></image>
			<view class="message">
				<u-icon name="chat-fill" color="#FFF" size="46" @click="navRoute('systemMessage')"></u-icon>
				<text class="message_num" v-if="data.msg_count">{{data.msg_count}}</text>
			</view>


			<view class="img_head">
				<image :src="data.pic" mode=""></image>
			</view>
			<view class="name" @click="li">
				{{data.user}}
			</view>
			<view class="integral">
				{{data.integral}}积分
			</view>
			<view class="card">
				<view class="item" @click="navRoute('collectList')">
					<view class="num">
						{{data.num_collect||0}}
					</view>
					<view class="text">
						收藏
					</view>

				</view>
				<view class="item" @click="navRoute('order')">
					<view class="num">
						{{data.num_order||0}}
					</view>
					<view class="text">
						课程
					</view>
				</view>
				<view class="item" @click="navRoute('myComment')">
					<view class="num">
						{{data.num_comm||0}}
					</view>
					<view class="text">
						评论
					</view>
				</view>
			</view>


		</view>
		<view class="ability">
			<view class="abilityItem" v-for="(item ,index) in list" @click="nav(item)">
				<image :src="item.logo" mode=""></image>
				<view class="">
					{{item.text}}
				</view>
				<u-icon name="arrow-right" class="icon" color="#ccc"></u-icon>
			</view>
		</view>
		<Loading />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
					text: '查看请假',
					path: '/pages/me/leaveList/leaveList',
					logo: '../../static/calendar.png'
				}, {
					text: '查看退课',
					logo: '../../static/calendar.png',
					path: '/pages/me/escCourse/escCourse'
				}, {
					text: '宝贝信息',
					path: '/pages/me/babyList/babyList',
					logo: '../../static/treasure.png'
				}, {
					text: '学校入驻',
					logo: '../../static/school.png',
					code: 1
				}, {
					text: '关于我们',
					logo: '../../static/oneself.png',
					path: '/pages/me/aboutUs/aboutUs'
				}, {
					text: '联系客服',
					logo: '../../static/service.png',
					code: 2
				}, {
					text: '退出登录',
					logo: '../../static/esc.png',
					path: '/pages/login/login'
				}],
				data: {}
			}
		},
		onShow() {
			this.newData()
		},
		methods: {
			newData() {
				this.$myRuquest('home/user/user').then(res => {
					if (res.code == 400) {
						this.data = res.data

					}
				})

				this.$myRuquest('home/index/seo_config')
			},
			nav(e) {
				const basic = uni.getStorageSync('basic');
				if (e.code == 2) return uni.makePhoneCall({
					phoneNumber: basic.pel
				});
				if (e.code == 1) return uni.navigateToMiniProgram({
					appId: 'wxaf3c47498e54bc17',
					path: 'pages/index/index',
					success(res) {
						// 打开成功
					}
				})
				let path = e.path
				uni.navigateTo({
					url: `${path}`
				});
			},

			navRoute(path) {
				uni.navigateTo({
					url: `./${path}/${path}`
				});
			},
		}
	}
</script>

<style lang="less" scoped>
	.content {
		background-color: rgb(247, 247, 247);
		height: 100vh;
	}

	.top {
		text-align: center;
		padding-top: 120upx;
		position: relative;
		z-index: 99;

		.bg {
			width: 100%;
			height: 540upx;
			position: absolute;
			top: 0;
			left: 0;
			z-index: -1;
			background-image: none;
		}

		.message {
			font-size: 36upx;
			position: absolute;
			right: 60upx;
			top: 180upx;

			.message_num {
				background-color: red;
				color: #fff;
				border-radius: 15upx;
				font-size: 24upx;
				width: 30upx;
				height: 30upx;
				line-height: 30upx;
				text-align: center;
				position: absolute;
				top: -10upx;
				right: -10upx;
			}
		}

		.img_head {
			width: 170upx;
			height: 170upx;
			border-radius: 50%;
			overflow: hidden;
			margin: 10upx auto;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.name {
			font-weight: 600;
			margin: 5upx 0;
			margin-top: 10upx;
			color: #fff;
		}

		.integral {
			color: #fff;
			font-size: 24upx;
		}

		.card {
			width: calc(100% - 40upx);
			padding: 20upx 0;
			margin: 20upx;
			margin-top: 30upx;
			border-radius: 12upx;
			box-shadow: 0 2upx 6upx rgba(0, 0, 0, .2);
			background: linear-gradient(to bottom, rgb(255, 255, 255), rgb(254, 246, 233));
			display: flex;

			.item {
				flex: 1;

				.num {
					color: rgb(255, 106, 98);
					font-size: 44upx;
				}
			}
		}
	}

	.ability {
		background-color: #fff;
		margin: 20upx;
		border-radius: 12upx;
		padding: 0 25upx;

		.abilityItem {
			display: flex;
			padding: 30upx 0;
			border-bottom: 2upx solid rgb(247, 247, 247);

			image {
				width: 40upx;
				height: 40upx;
				margin-right: 20upx;
				background-image: none;
			}

			.icon {
				position: absolute;
				right: 30upx;
			}
		}
	}
</style>
